# KnowzCode: [LOOP 3] Finalize & Commit Change Set

**WorkGroupID for Finalization:**
[Orchestrator: Re-state the `WorkGroupID` that has passed implementation and verification, authorizing its finalization and commit.]

> **Automation Path:** Execute `/knowzcode-step phase=3 workgroup_id=<ID>` to hand off to the `closer` subagent. It chains `tracker-update`, `log-entry-builder`, and `architecture-diff` skills to wrap up the loop.

**Remember:**
- Finalize every spec in `knowzcode/specs/` to reflect the as-built system.
- Close or add remaining todos in `knowzcode/workgroups/<WorkGroupID>.md`, ensuring all entries keep the `KnowzCode:` prefix.

**WorkGroupID:** `[wip-timestamp-to-finalize]`

---

## Your Mission
The implementation and verification for the specified `WorkGroupID` is complete. You are now authorized to execute the final phase of the KnowzCode loop: documentation, logging, and committing.

**CRITICAL RULE: The implementation phase is complete. Your work in this phase is strictly limited to updating KnowzCode's own project and specification files (`.md` files) to reflect the finished work. You MUST NOT write or modify any more application source code (e.g., `.js`, `.py`, `.html` files).**

**Reference:** Your actions are governed by `knowzcode_loop.md`, executing the sequence from **Step 7 through Step 10**.

---

### Execution Protocol

1.  **Finalize Specifications (Step 7):**
    *   For **each** `NodeID` in the `WorkGroupID`, update its spec file in `specs/` to the "as-built" state, ensuring it perfectly reflects the verified code.

2.  **Check Architecture (Step 8):**
    *   Conduct the Flowchart Consistency Check. If you find a simple discrepancy, fix `knowzcode_architecture.md` directly. If it's complex, document it in the log.

3.  **Log Operation (Step 9):**
    *   Create the single, comprehensive `ARC-Completion` log entry in `knowzcode_log.md`. Ensure it includes the flowchart check outcome, any unforeseen ripple effects, and project overview updates. Use an environment-sourced timestamp.

4.  **Update Tracker, Schedule Debt, & Check Project Overview (Step 10):**
    *   **Update Tracker:** In `knowzcode_tracker.md`, mark all nodes in the `WorkGroupID` as `[VERIFIED]` and clear their `WorkGroupID`.
    *   **Schedule Debt:** Perform the "Technical Debt Scheduling" step. For any nodes with documented debt, create new `REFACTOR_` tasks in the tracker.
    *   **Update Project Overview:** Check if this Change Set impacts `knowzcode_project.md`:
        - New major features → Update "Key Features" section
        - New libraries/tools → Update "Technology Stack" table
        - Architecture changes → Update "Architecture Decisions"
        - Scope expansion → Update "Scope & Key Features"
    *   **Final Commit:** Inspect `git status --short` and scoped diffs, resolve the explicit approved final file list, stage only those paths with `git add -- {explicit-paths}`, verify `git diff --cached --check` and the exact cached name list, then commit with a descriptive `feat:` message. Never stage unrelated or ambiguous user state.

### Final Report

*   Once all steps above are complete, provide a final confirmation report.

**Example Response Format:**
> "Finalization for `WorkGroupID: [ID]` is complete.
>
> *   All specifications have been updated to the 'as-built' state.
> *   The architecture flowchart has been checked and updated.
> *   A complete `ARC-Completion` entry has been logged.
> *   The tracker is updated, and all nodes are now `[VERIFIED]`.
> *   **Project Overview Updates:** [None | Updated sections: Technology Stack, Key Features]
> *   The final `feat:` commit has been made to version control.
> *   **New Refactor Tasks Created:** [List any REFACTOR_ nodes created, or 'None'].
>
> This Change Set is now fully complete and documented. Awaiting next `PrimaryGoal` via a new Work Session."

### Final State

*   Upon successful completion, the KnowzCode loop for this `WorkGroupID` is **finished**. You will return to an idle state.

---
